//
//  WHLoginModel.m
//  WHEasyBizLink
//
//  Created by shengmeng chen on 2024/12/9.
//
#define archiverPath  [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:@"WHLoginModel.archiver"]

#import "WHLoginModel.h"
#import "NSObject+MJCoding.h"

@implementation WHLoginModel

//自定的模型的要实现
MJCodingImplementation

//保存用户信息
+ (BOOL)saveLoginModel:(WHLoginModel *)loginModel{

    //DebugLog(@"archiverPath =%@",archiverPath);
    return [NSKeyedArchiver archiveRootObject:loginModel toFile:archiverPath];
}

//删除用户信息

+ (BOOL)deleteLoginModel{
    
    NSError *error;
   return [[NSFileManager defaultManager]removeItemAtPath:archiverPath error:&error];
}

//取出用户信息
+ (instancetype)getLoginModel{
    
    if ([NSKeyedUnarchiver unarchiveObjectWithFile:archiverPath]) {
        return [NSKeyedUnarchiver unarchiveObjectWithFile:archiverPath];
    }else{
        
        WHLoginModel *loginModel = [[WHLoginModel alloc]init];
        return  loginModel;
    }
}

@end
